#include <iostream>
#include <vector>
using namespace std;

vector<int> stations; // 加油站间距
int dist;             // 满油的行驶距离
int num;              // 加油站数量
int countN = 0;       // 记录加油次数
int left_dist;        // 剩余油可以走的距离

void get_Fuel()
{
    for (int i = 0; i < num; i++)
    {
        //如果油量可以支撑下一段路，则继续走 
        if (stations[i] > dist)
        {
            cout << "汽车不可能达到终点站" << endl;
            return;
        }
        if (left_dist >= stations[i])
        {
            left_dist -= stations[i];
        }
        else
        {
            //否则加满油 
            left_dist = dist - stations[i];
            countN++;
        }
    }

    cout << "一共需要加油" << countN << "次" << endl;
}

int main()
{
    cout << "请输入加满油的行驶距离和加油站数量" << endl;
    cin >> dist >> num; // 7 4
    left_dist = dist;

    cout << "请输入" << num << "个间距：" << endl;
    for (int i = 0; i < num; i++) // 2 7 3 6
    {
        int tmp;
        cin >> tmp;
        stations.push_back(tmp);
    }

    get_Fuel(); // 3
    return 0;
}